//
//  OEPresupShopTableViewCell.m
//  OneEightyNine
//
//  Created by Mac on 2019/3/5.
//  Copyright © 2019 stoneobs. All rights reserved.
//

#import "OEHotOfferTableViewCell.h"

@interface  OEHotOfferTableViewCell()
@property(nonatomic, strong) UIImageView                     *iconImageView;/**<  */

@property(nonatomic, strong) STLabel                     *titleLable;/**<  */
@property(nonatomic, strong) STButton                     *timeButton;/**<  */

@property(nonatomic, strong) STLabel                     *distenceLable;/**<  */
@property(nonatomic, strong) STButton                     *addButton;/**<  */

@property(nonatomic, strong) STButton                     *allButton;/**<  */
@property(nonatomic, strong) STButton                     *borrowButton;/**<  */
@property(nonatomic, strong) STButton                     *retunButton;/**<  */
@end
@implementation OEHotOfferTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configSubView];
    }
    return self;
}
+ (CGFloat)cellHeight{
    return 150;
}
#pragma mark --subView
- (void)configSubView{
    self.backgroundColor = UIColor.clearColor;
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    
    UIView * whiteView = [[UIView alloc] initWithFrame:CGRectMake(20, 0, UIScreenWidth - 40, 140)];
    whiteView.layer.cornerRadius = 10;
    whiteView.clipsToBounds = YES;
    whiteView.backgroundColor = UIColor.whiteColor;
    [self addSubview:whiteView];
    
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 70, 70)];
    imageView.image = [UIImage imageNamed:@""];
    [whiteView addSubview:imageView];
    imageView.clipsToBounds = YES;
    imageView.layer.cornerRadius = 8;
    self.iconImageView = imageView;
    CGFloat maxWitdh = whiteView.width - imageView.right - 10;
    
    self.titleLable = [[STLabel alloc] initWithFrame:CGRectMake(imageView.right + 10, imageView.top, maxWitdh, 30)
                                                text:@""
                                           textColor:FirstTextColor
                                                font:17
                                         isSizetoFit:NO
                                       textAlignment:NSTextAlignmentLeft];
    [whiteView addSubview:self.titleLable];
    
    self.timeButton = [[STButton alloc] initWithFrame:CGRectMake(self.titleLable.left, self.titleLable.bottom, maxWitdh, 20)
                                                title:@""
                                           titleColor:SecendTextColor
                                            titleFont:14
                                         cornerRadius:0
                                      backgroundColor:nil
                                      backgroundImage:nil
                                                image:[UIImage imageNamed:@"24×24时间"]];
    [whiteView addSubview:self.timeButton];
    
    self.addButton = [[STButton alloc] initWithFrame:CGRectMake(self.titleLable.left, self.timeButton.bottom, maxWitdh - 100, 20)
                                               title:@""
                                          titleColor:SecendTextColor
                                           titleFont:12
                                        cornerRadius:0
                                     backgroundColor:UIColor.whiteColor
                                     backgroundImage:nil
                                               image:[UIImage imageNamed:@"24×30地址"]];
    [whiteView addSubview:self.addButton];
    self.addButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
    self.timeButton.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
    
    self.distenceLable = [[STLabel alloc] initWithFrame:CGRectMake(0, 0, 100, 20)
                                                   text:@""
                                              textColor:SecendTextColor
                                                   font:13
                                            isSizetoFit:NO
                                          textAlignment:NSTextAlignmentRight];
    self.distenceLable.centerY = self.addButton.centerY;
    self.distenceLable.right = whiteView.width - 10;
    [whiteView addSubview:self.distenceLable];
    
    UIView * line = [[UIView alloc] initWithFrame:CGRectMake(0, whiteView.height - 44.5, whiteView.width, 0.5)];
    line.backgroundColor =TM_lineColor;
    [whiteView addSubview:line];
    
    self.allButton = [[STButton alloc] initWithFrame:CGRectMake(0, whiteView.height - 44, whiteView.width / 3, 40)
                                               title:OESTRING(@"All 20")
                                          titleColor:OE_LIMITE_COLOR
                                           titleFont:15
                                        cornerRadius:0
                                     backgroundColor:UIColor.whiteColor
                                     backgroundImage:nil
                                               image:nil];
    self.allButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.allButton st_showRightLine:20];
    [whiteView addSubview:self.allButton];
    
    self.borrowButton = [[STButton alloc] initWithFrame:CGRectMake(self.allButton.right, whiteView.height - 44, whiteView.width / 3, 40)
                                               title:OESTRING(@"BORROW 20")
                                          titleColor:FlatOrange
                                           titleFont:15
                                        cornerRadius:0
                                     backgroundColor:UIColor.whiteColor
                                     backgroundImage:nil
                                               image:nil];
    self.borrowButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [self.borrowButton st_showRightLine:20];
    [whiteView addSubview:self.borrowButton];
    
    self.retunButton = [[STButton alloc] initWithFrame:CGRectMake(self.borrowButton.right, whiteView.height - 44, whiteView.width / 3, 40)
                                                  title:OESTRING(@"BORROW 20")
                                             titleColor:FlatBlue
                                              titleFont:15
                                           cornerRadius:0
                                        backgroundColor:UIColor.whiteColor
                                        backgroundImage:nil
                                                  image:nil];
    self.retunButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [whiteView addSubview:self.retunButton];
}
- (void)setModel:(OEShopEasyModel *)model{
    _model = model;
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:model.supplier_logo]];
    self.titleLable.text = model.supplier_name;
    
    [self.timeButton setTitle:[NSString stringWithFormat:@"%@-%@",model.start_time,model.end_time] forState:UIControlStateNormal];
    [self.addButton setTitle:[NSString stringWithFormat:@"%@",model.address] forState:UIControlStateNormal];
    
    self.distenceLable.text = model.distance;
    
    
    [self.allButton setTitle:[NSString stringWithFormat:@"ALL %@",model.share_count] forState:UIControlStateNormal];
    [self.borrowButton setTitle:[NSString stringWithFormat:@"BORROW %@",model.borrow_count] forState:UIControlStateNormal];
    [self.retunButton setTitle:[NSString stringWithFormat:@"Return %@",model.return_count] forState:UIControlStateNormal];
}
@end
